package es.pawer.android.listacompras;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import es.pawer.android.listacompras.biz.Item;

public class ArrayItemAdapter extends ArrayAdapter<Item> {

	public ArrayItemAdapter(Context context, List<Item> objects) {
		super(context,android.R.layout.simple_list_item_1, objects);
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater)this.getContext().getSystemService(
	      Context.LAYOUT_INFLATER_SERVICE);
		LinearLayout ll=(LinearLayout)inflater.inflate(R.layout.list_item, null);
		TextView tv=(TextView)ll.getChildAt(0);
		tv.setText(this.getItem(position).getName());
		tv=(TextView)ll.getChildAt(1);
		tv.setText(this.getItem(position).getUnits()+" units");
		return ll;
	}

	
}
